﻿using DotNetExtensions.Core.Helpers;
using DotNetExtensions.Core.MVC;
using DotNetExtensions.Core.WebApi.Jwt;
using ManagedNativeWifi;
using DotNetExtensions.Core.Http;
using DotNetExtensions.Core.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DotNetExtensions.Core;
using System.Diagnostics;
using DotNetExtensions.Core.Compress;

namespace CoreSimple
{
    class Program
    {
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            //FixedList<int> list = new FixedList<int>(10);
            //for (int i = 0; i < 100; i++)
            //{
            //    list.Add(i);
            //}
            //var task1 = Task.Factory.StartNew(() =>
            //{
            //    for (int i = 10000; i > 0; i--)
            //    {
            //        list.Add(i);
            //    }
            //});
            //var task2 = Task.Factory.StartNew(() =>
            //{
            //    for (int i = 0; i < 10000; i++)
            //    {
            //        list.Add(i);
            //    }
            //});
            ZipCompressor.Zip(@"C:\Workspace\RequestLogs\202307\2711", @"C:\Workspace\RequestLogs\202307\\2711.zip");

            //FileIdTest test = new FileIdTest();

            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();
            //List<Task> tasks = new List<Task>();
            //for (int i = 0; i < 100; i++)
            //{
            //    var t = Task.Run(() =>
            //     {
            //         for (int i = 0; i < 10000; i++)
            //         {
            //             test.Get("Test");
            //         }
            //     });
            //    tasks.Add(t);
            //}
            //Task.WaitAll(tasks.ToArray());
            //stopwatch.Stop();
            //Console.WriteLine("10W耗时:{0}", stopwatch.ElapsedMilliseconds);
            //Task.WaitAll(task1, task2);
            //Console.WriteLine(string.Join(",", list));
            //var response = new HttpResponse(200, "{\"success\":false,\"message\":\"操作失败，JSON parse error: Cannot deserialize value of type `java.lang.Integer` from Boolean value (token `JsonToken.VALUE_TRUE`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.Integer` from Boolean value (token `JsonToken.VALUE_TRUE`)\n at[Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 518] (through reference chain: org.aps.modules.adapter.entity.vo.BasMaterialBomVO[\\\"basMaterialBomChildVOList\\\"]->java.util.ArrayList[0]->org.aps.modules.adapter.entity.vo.BasMaterialBomChildVO[\\\"invented\\\"])\", \"code\":500, \"result\":null, \"timestamp\":1688442418156}");
            //bool ret = response.ToJson().TryGetValue("code", out int value);
            //Console.WriteLine("ret={0}, value={1}", ret, value);
            //JwtParameters para = new JwtParameters();
            //para.Add(new JwtParameter("1", "2"));
            //para.Add(new JwtParameter("2", "4"));
            // MapperTest.Run();
            // TypeSimple.Parse();
            // MapperTest.TestLong();
            // new MethodTypeParseTest().TestParseJson();
            // MapperTest.Run();
            //var test = new SnowflakeTest();
            //test.Start();
            //string v = AppSettingDefault.GetValue<string>("ConnectionStrings.JIAOHXIONG");
            //Console.WriteLine(v);
            //Console.WriteLine(typeof(AppSettingDefault).Assembly.GetName().FullName);
            // Console.WriteLine(TypeHelper.IsArray(typeof(object[])));
            //new MethodTypeParseTest().Test();
            // new LogWithLog4NetTest().Log();
            // MapperTest.Run();

            // MaxVersionTest.Run();
            //List<Redpack> packs = new List<Redpack>();
            //List<int> valiables = new List<int>();
            //for (int i = 0; i < 100; i++)
            //{
            //    var pack = new RedpackTest().Create();
            //    packs.Add(pack);
            //    valiables.Add(1);
            //}
            //DateTime d = DateTime.Now;
            //while (valiables.Contains(1))
            //{
            //    Task.Factory.StartNew(() =>
            //    {
            //        int id = new Random().Next(0, 100);
            //        if (id > -1 && id < 100)
            //        {
            //            var p = packs[id];
            //            if (p.CanNext())
            //            {
            //                decimal m = p.Next();
            //                Console.WriteLine("红包：{0:D3} - 我抢了￥{1:00.00}", id, m);
            //            }
            //            else
            //            {
            //                valiables[id] = 0;
            //            }
            //        }
            //    });
            //}

            //Console.WriteLine("来迟了，红包雨已结束，{0}/秒", (DateTime.Now - d).TotalSeconds);

            //Timer timer = new Timer(new TimerCallback((obj) =>
            //{
            //    new RedpackTest().Valid();
            //}), null, 1000, 500);

            //var wifi = NativeWifi.EnumerateAvailableNetworkSsids().Select(x => x.ToString());

            //foreach (var item in wifi)
            //{
            //    Console.WriteLine(item);
            //}


            // Console.WriteLine("Hello World!");
            // new IOC.IOC_Simple();

            // string[] fiels = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "System.*.dll");

            //new PKCS1_Simple();
            //new PKCS8_Simple();

            // var restful = new RestfulHttpClientSimple();
            // restful.TestCookie();
            // restful.TestMultipleFormData();
            //restful.TestGetFormData();
            // restful.TestFormData();
            // restful.TestGet();
            // restful.TestJsonData();
            // restful.TestJsonData2();

            // TypeSimple.Parse();
            stopwatch.Stop();
            Console.WriteLine("耗时: {0} ms", stopwatch.ElapsedMilliseconds);
            Console.ReadLine();
        }
    }
}
